package com.edu.exam.enums.examination.paper;

import com.edu.exam.enums.core.StatusEnum;

/**
 * 试卷处理任务状态枚举
 * 用于试卷分割、图像处理、OM识别、扫描识别等技术处理任务
 *
 * @author System
 * @version 1.0.0
 */
public enum PaperProcessingTaskStatus implements StatusEnum {

    // === 初始状态 ===
    CREATED("CREATED", "已创建"),
    PENDING("PENDING", "待处理"),
    QUEUED("QUEUED", "队列中"),
    ASSIGNED("ASSIGNED", "已分配"),

    // === 进行中状态 ===
    RUNNING("RUNNING", "执行中"),
    PROCESSING("PROCESSING", "处理中"),
    IN_PROGRESS("IN_PROGRESS", "进行中"),
    ACTIVE("ACTIVE", "活跃"),

    // === 完成状态 ===
    COMPLETED("COMPLETED", "已完成"),
    FINISHED("FINISHED", "已结束"),
    SUCCESS("SUCCESS", "成功"),
    RESOLVED("RESOLVED", "已解决"),

    // === 失败状态 ===
    FAILED("FAILED", "失败"),
    ERROR("ERROR", "错误"),
    CANCELLED("CANCELLED", "已取消"),
    ABORTED("ABORTED", "已中止"),
    TIMEOUT("TIMEOUT", "超时"),

    // === 暂停状态 ===
    PAUSED("PAUSED", "已暂停"),
    SUSPENDED("SUSPENDED", "已挂起"),
    ON_HOLD("ON_HOLD", "保留"),

    // === 其他状态 ===
    SKIPPED("SKIPPED", "已跳过"),
    RETRY("RETRY", "重试中"),
    EXPIRED("EXPIRED", "已过期"),
    UNKNOWN("UNKNOWN", "未知");

    private final String code;
    private final String description;

    PaperProcessingTaskStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static PaperProcessingTaskStatus fromCode(String code) {
        for (PaperProcessingTaskStatus value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unknown paper processing task status code: " + code);
    }

    public static PaperProcessingTaskStatus fromDescription(String description) {
        for (PaperProcessingTaskStatus value : values()) {
            if (value.getDescription().equals(description)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unknown paper processing task status description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}